package domain.entities;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import javax.persistence.*;
import java.util.*;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Centro entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "centro", catalog = "bms")
public class Centro implements java.io.Serializable {

	// Fields

	private Integer id;
	private int bookBa;
	private String corporateName;
	private String gryaSosComment;
	private String gryaSosName;
	private int idBa;
	private String institucion;
	private String legalRepresentative;
	private int pageBa;
	private String psaContactInformation;
	private String psaReferredBy;
    private String webPage;
    private Date registerDateBa;
    private String gln;
	private String requiresIecapproval;
	private int rutCorporate;
	private int rutLegalRepresentative;
    private String status;
    private Set<ComiteDocencia> comiteDocencias = new HashSet<ComiteDocencia>(0);
	private Set<Cdamaster> cdamasters = new HashSet<Cdamaster>(0);
	private Set<ProtocoloCentro> protocoloCentros = new HashSet<ProtocoloCentro>(
			0);
	private Set<Involucrado> involucrados = new HashSet<Involucrado>(0);
	private List<CentroAddress> centroAddresses = new ArrayList<CentroAddress>(0);

    private String eclipseId;

	// Constructors

	/** default constructor */
	public Centro() {
	}

    public Centro(Integer id, String institucion) {
        this.id = id;
        this.institucion = institucion;
    }

	/** full constructor */
	public Centro(int bookBa, String corporateName,
			String gryaSosComment, String gryaSosName,
			int idBa, String institucion, String legalRepresentative,
			int pageBa, String psaContactInformation, String psaReferredBy,
			Date registerDateBa, String requiresIecapproval,
			int rutCorporate, int rutLegalRepresentative,
            String gln,
			Set<ComiteDocencia> comiteDocencias,
			Set<Cdamaster> cdamasters, Set<ProtocoloCentro> protocoloCentros,
			Set<Involucrado> involucrados,
			ArrayList<CentroAddress> centroAddresses) {
		this.bookBa = bookBa;
		this.corporateName = corporateName;
		this.gryaSosComment = gryaSosComment;
		this.gryaSosName = gryaSosName;
		this.idBa = idBa;
		this.institucion = institucion;
		this.legalRepresentative = legalRepresentative;
		this.pageBa = pageBa;
		this.psaContactInformation = psaContactInformation;
		this.psaReferredBy = psaReferredBy;
		this.registerDateBa = registerDateBa;
		this.requiresIecapproval = requiresIecapproval;
		this.rutCorporate = rutCorporate;
		this.rutLegalRepresentative = rutLegalRepresentative;
		this.comiteDocencias = comiteDocencias;
		this.cdamasters = cdamasters;
		this.protocoloCentros = protocoloCentros;
		this.involucrados = involucrados;
		this.centroAddresses = centroAddresses;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "bookBA")
	public int getBookBa() {
		return this.bookBa;
	}

	public void setBookBa(int bookBa) {
		this.bookBa = bookBa;
	}

	@Column(name = "corporateName")
	public String getCorporateName() {
		return this.corporateName;
	}

	public void setCorporateName(String corporateName) {
		this.corporateName = corporateName;
	}

	@Column(name = "gryaSosComment")
	public String getGryaSosComment() {
		return this.gryaSosComment;
	}

	public void setGryaSosComment(String gryaSosComment) {
		this.gryaSosComment = gryaSosComment;
	}

	@Column(name = "gryaSosName")
	public String getGryaSosName() {
		return this.gryaSosName;
	}

	public void setGryaSosName(String gryaSosName) {
		this.gryaSosName = gryaSosName;
	}

	@Column(name = "idBA")
	public int getIdBa() {
		return this.idBa;
	}

	public void setIdBa(int idBa) {
		this.idBa = idBa;
	}

    @Column(name = "webPage")
    public String getWebPage() {
        return this.webPage;
    }

    public void setWebPage(String webPage) {
        this.webPage = webPage;
    }

	@Column(name = "institucion")
	public String getInstitucion() {
		return this.institucion;
	}

	public void setInstitucion(String institucion) {
		this.institucion = institucion;
	}

	@Column(name = "legalRepresentative")
	public String getLegalRepresentative() {
		return this.legalRepresentative;
	}

	public void setLegalRepresentative(String legalRepresentative) {
		this.legalRepresentative = legalRepresentative;
	}

    @Column(name = "gln")
    public String getGln() {
        return gln;
    }

    public void setGln(String gln) {
        this.gln = gln;
    }

    @Column(name = "pageBA")
	public int getPageBa() {
		return this.pageBa;
	}

	public void setPageBa(int pageBa) {
		this.pageBa = pageBa;
	}

	@Column(name = "psaContactInformation")
	public String getPsaContactInformation() {
		return this.psaContactInformation;
	}

	public void setPsaContactInformation(String psaContactInformation) {
		this.psaContactInformation = psaContactInformation;
	}

	@Column(name = "psaReferredBy")
	public String getPsaReferredBy() {
		return this.psaReferredBy;
	}

	public void setPsaReferredBy(String psaReferredBy) {
		this.psaReferredBy = psaReferredBy;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "registerDateBA", length = 10)
	public Date getRegisterDateBa() {
		return this.registerDateBa;
	}

	public void setRegisterDateBa(Date registerDateBa) {
		this.registerDateBa = registerDateBa;
	}

	@Column(name = "requiresIECApproval")
	public String getRequiresIecapproval() {
		return this.requiresIecapproval;
	}

	public void setRequiresIecapproval(String requiresIecapproval) {
		this.requiresIecapproval = requiresIecapproval;
	}

	@Column(name = "rutCorporate")
	public int getRutCorporate() {
		return this.rutCorporate;
	}

	public void setRutCorporate(int rutCorporate) {
		this.rutCorporate = rutCorporate;
	}

	@Column(name = "rutLegalRepresentative")
	public int getRutLegalRepresentative() {
		return this.rutLegalRepresentative;
	}

	public void setRutLegalRepresentative(int rutLegalRepresentative) {
		this.rutLegalRepresentative = rutLegalRepresentative;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "centro")
	public Set<ComiteDocencia> getComiteDocencias() {
		return this.comiteDocencias;
	}

	public void setComiteDocencias(Set<ComiteDocencia> comiteDocencias) {
		this.comiteDocencias = comiteDocencias;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "centro")
	public Set<Cdamaster> getCdamasters() {
		return this.cdamasters;
	}

	public void setCdamasters(Set<Cdamaster> cdamasters) {
		this.cdamasters = cdamasters;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "centro")
	public Set<ProtocoloCentro> getProtocoloCentros() {
		return this.protocoloCentros;
	}

	public void setProtocoloCentros(Set<ProtocoloCentro> protocoloCentros) {
		this.protocoloCentros = protocoloCentros;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "centro")
	public Set<Involucrado> getInvolucrados() {
		return this.involucrados;
	}

	public void setInvolucrados(Set<Involucrado> involucrados) {
		this.involucrados = involucrados;
	}

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "centro")
    @LazyCollection(LazyCollectionOption.FALSE)
	public List<CentroAddress> getCentroAddresses() {
		return this.centroAddresses;
	}

	public void setCentroAddresses(List<CentroAddress> centroAddresses) {
		this.centroAddresses = centroAddresses;
	}

    private RemoteAccess remoteAccess;

    @OneToOne(cascade = CascadeType.ALL)
    public RemoteAccess getRemoteAccess() {
        return remoteAccess;
    }

    public void setRemoteAccess(RemoteAccess remoteAccess) {
        this.remoteAccess = remoteAccess;
    }

    @Column(name = "eclipseId")
    public String getEclipseId() {
        return this.eclipseId;
    }

    public void setEclipseId(String eclipseId) {
        this.eclipseId = eclipseId;
    }


    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Centro)) return false;

        Centro centro = (Centro) o;

        if (!id.equals(centro.id)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
}